requireJS(['constant', 'site', 'handlebars'], function (Constant, site, Handlebars) {
    var refreshHead = function () {
        Handlebars.registerHelper('if_eq', function(v1, v2, opts) {
            if(v1 == v2)
                return opts.fn(this);
            else
                return opts.inverse(this);
        });
        var menuIndex = getAurlparam('h')
        var menuIndex2 = getAurlparam('i')
        //获取服务端返回的content,渲染顶部菜单
        var content = JSON.parse(localStorage.getItem('content'));
        if( !$("#a-content-tpl").html() ) {
            return;
        }
        var headerTpl = Handlebars.compile($("#a-content-tpl").html());
        $('#a-content').html(headerTpl(content.menus[menuIndex].children[menuIndex2].children));
        //切换
        $(".public-List").each(function (i) {
            $(this).on('click', function () {
                // $(this).addClass("publicListHover")
                // $(".public-List").not(this).removeClass("publicListHover")
                var url = $(this).data("url");
                if( url ){
                    pjaxGo( url );
                }
            });
        });
    }
    refreshHead();

    $(document).on('pjax:end', function() {//pjax结束刷新一遍左侧和头部
        refreshHead();
    });
})